import sys


def main(a_file, b_file):
    a = read_into_set(a_file)
    b = read_into_set(b_file)
    write_set_to_file('interset.txt', a & b)
    write_set_to_file('a-b.txt', a - b)
    write_set_to_file('b-a.txt', b - a)


def write_set_to_file(filepath: str, s):
    with open(filepath, 'w', encoding='utf-8') as f:
        f.writelines([x+'\n' for x in s])


def read_into_set(filepath: str) -> set:
    with open(filepath, 'r', encoding='utf-8') as f:
        return set([x.strip() for x in f])


if __name__ == '__main__':
    main(sys.argv[1], sys.argv[2])
